﻿using System.Collections.Generic;
using MyWindowsService.Entity;
using PetaPoco;

namespace MyWindowsService.Tools
{
    public class SqlService
    {
        private Database _db;
        public SqlService()
        {
            _db = new Database("ConnectionString");
        }

        public List<HSParam> GetMessages(int start, int end)
        {
            var sql = $@"
            SELECT
	            *
            FROM
	            (
		            SELECT *,ROW_NUMBER() OVER(ORDER BY id) rn FROM hsparam
	            )a
            WHERE
	            a.rn BETWEEN {start} and {end} ";

            return _db.Fetch<HSParam>(sql);
        }
    }
}
